package com.example.iitematicviewer.api.author;

import com.alibaba.fastjson.JSONObject;
import com.example.iitematicviewer.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 作者控制层
 */
@RequestMapping("/author")
@RestController
public class AuthorController {

    @Autowired
    private AuthorService service;

    /**
     * 作者新增方法
     * @param param
     * @return
     */
    @RequestMapping("/save")
    public ResultVO save(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        return service.save(param,resultVO);
    }

    /**
     * 作者修改方法
     * @param param
     * @return
     */
    @RequestMapping("/update")
    public ResultVO update(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        return service.update(param,resultVO);
    }

    /**
     * 作者删除方法
     * @param param
     * @return
     */
    @RequestMapping("/delete")
    public ResultVO delete(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        return service.delete(param,resultVO);
    }

    /**
     * 作者表查询方法
     * @param param
     * @return
     */
    @RequestMapping("/selectAuthor")
    public ResultVO selectAuthor(@RequestBody(required = false) JSONObject param){
        ResultVO resultVO = new ResultVO();
        return service.selectAuthor(param,resultVO);
    }
}
